<?php

namespace App\Http\Controllers\H5;
use App\Http\Controllers\BaseController;
use App\Services\Base\RegionService;
use App\Traits\HttpRequestTrait;
/**
 * 首页控制器
 *
 * @author WangBin
 * @date 2021-09-24
 * @package App\Http\Controllers\H5
 */
class HomeController extends BaseController
{
    use HttpRequestTrait;

    /**
     * 首页数据初始化
     *
     * @return
     */
    public function init()
    {
        $data = [
            "page" => [
                "name" => "页面设置",
                "type" => "page",
                "params" => [
                    "name" => "商城首页",
                    "title" => "HiYee-商城",
                    "shareTitle" => "分享标题"
                ],
                "style" => [
                    "titleTextColor" => "black",
                    "titleBackgroundColor" => "#ffffff"
                ]
            ],
            "items" => [
                [
                    "name" => "搜索框",
                    "type" => "search",
                    "params" => [
                        "placeholder" => "请输入关键字进行搜索"
                    ],
                    "style" => [
                        "textAlign" => "left",
                        "searchStyle" => "round"
                    ]
                ],
                [
                    "name" => "图片轮播",
                    "type" => "banner",
                    "style" => [
                        "btnColor" => "#d5a988",
                        "btnShape" => "round",
                        "interval" => 20
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/295000dccb12fe8d7fad7bc4814ec6f4.png",
                            "link" => [
                                "id" => "6wawb10",
                                "title" => "商品详情页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/detail",
                                    "query" => [
                                        "goodsId" => "10018"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.goodsId",
                                        "lable" => "商品ID",
                                        "required" => true,
                                        "tips" => "商品管理 - 商品列表",
                                        "value" => "10018"
                                    ]
                                ]
                            ],
                            "imgName" => "banner02.png"
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/1938bdd93e11675179b20410dabef3cc.png",
                            "link" => null,
                            "imgName" => "未标题-1.png"
                        ]
                    ]
                ],
                [
                    "name" => "店铺公告",
                    "type" => "notice",
                    "params" => [
                        "text" => "萤火科技 致力于通过产品和服务，帮助商家高效化开拓市场。当前为演示商城，所有商品均为测试数据，请勿下单（不发货）。",
                        "link" => null,
                        "showIcon" => true,
                        "scrollable" => true
                    ],
                    "style" => [
                        "paddingTop" => 1,
                        "background" => "#fffbe8",
                        "textColor" => "#de8c17"
                    ]
                ],
                [
                    "name" => "导航组",
                    "type" => "navBar",
                    "style" => [
                        "rowsNum" => 4,
                        "background" => "#ffffff",
                        "paddingTop" => 3,
                        "textColor" => "#666666"
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210315/8749305b19496b7b5b0b098837357a80.png",
                            "imgName" => "icon-2.jpg",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10085",
                                        "search" => ""
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10085"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ],
                            "text" => "居家生活"
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210315/003ebfff145bd74289b8ad5510b6a01e.png",
                            "imgName" => "icon-3.jpg",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10001",
                                        "search" => ""
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10001"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ],
                            "text" => "手机数码"
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210315/49251b6557e20faee7c67d9ee331a98b.png",
                            "imgName" => "icon-1.png",
                            "link" => [
                                "id" => "56sswhq",
                                "title" => "领券中心",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/coupon/index"
                                ]
                            ],
                            "text" => "领券中心"
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210315/7a5fde286eb3c79e80be0b3f82f2079b.png",
                            "imgName" => "icon-4.jpg",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10088",
                                        "search" => ""
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10088"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ],
                            "text" => "运动户外"
                        ]
                    ]
                ],
                [
                    "name" => "图片",
                    "type" => "image",
                    "style" => [
                        "paddingTop" => 0,
                        "paddingLeft" => 0,
                        "background" => "#ffffff"
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/0e7f6417ccccc90cf48f1359ea85ecc9.png",
                            "imgName" => "1(1).png",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10085"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10085"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ]
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/a33f3214d24b6268d0262dcb16a93fd2.png",
                            "imgName" => "2(1).png",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10085"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10085"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ]
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/1e9050ee367a64f99db4aff8e2d38a2d.png",
                            "imgName" => "3(1).png",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10085"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10085"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ]
                        ]
                    ]
                ],
                [
                    "name" => "图片",
                    "type" => "image",
                    "style" => [
                        "paddingTop" => 5,
                        "paddingLeft" => 0,
                        "background" => "#ffffff"
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/0607338b08e9845b6db6b90d83da0f58.png",
                            "imgName" => "未标题-2.png",
                            "link" => null
                        ]
                    ]
                ],
                [
                    "name" => "图片",
                    "type" => "image",
                    "style" => [
                        "paddingTop" => 0,
                        "paddingLeft" => 0,
                        "background" => "#ffffff"
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/d16e7e7bd8735e4bf04cc5a463c65016.png",
                            "imgName" => "华为.png",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10011"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10011"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ]
                        ]
                    ]
                ],
                [
                    "name" => "图片橱窗",
                    "type" => "window",
                    "style" => [
                        "paddingTop" => 0,
                        "paddingLeft" => 0,
                        "background" => "#ffffff",
                        "layout" => 2
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/6e25a66132754fe4cad0ae88b7a8544c.png",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10010"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10010"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ],
                            "imgName" => "小米.png"
                        ],
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/e4d48985f825c73f82ad9690424e1db1.png",
                            "link" => [
                                "id" => "995bf1c",
                                "title" => "商品列表页",
                                "type" => "PAGE",
                                "param" => [
                                    "path" => "pages/goods/list",
                                    "query" => [
                                        "categoryId" => "10012"
                                    ]
                                ],
                                "form" => [
                                    [
                                        "key" => "query.categoryId",
                                        "lable" => "分类ID",
                                        "tips" => "商品管理 -> 商品分类",
                                        "value" => "10012"
                                    ],
                                    [
                                        "key" => "query.search",
                                        "lable" => "关键词",
                                        "tips" => "搜索的关键词，用于匹配商品名称",
                                        "value" => ""
                                    ]
                                ]
                            ],
                            "imgName" => "苹果.png"
                        ]
                    ],
                    "dataNum" => 4
                ],
                [
                    "name" => "图片",
                    "type" => "image",
                    "style" => [
                        "paddingTop" => 3,
                        "paddingLeft" => 0,
                        "background" => "#ffffff"
                    ],
                    "data" => [
                        [
                            "imgUrl" => "http://static.yoshop.xany6.com/10001/20210314/aefe0a60bb4c59c88a1d463bbe6b5198.png",
                            "imgName" => "111_看图王.web.png",
                            "link" => null
                        ]
                    ]
                ],
                [
                    "name" => "商品组",
                    "type" => "goods",
                    "params" => [
                        "source" => "auto",
                        "auto" => [
                            "category" => 0,
                            "goodsSort" => "all",
                            "showNum" => 40
                        ]
                    ],
                    "style" => [
                        "background" => "#F6F6F6",
                        "display" => "list",
                        "column" => 2,
                        "show" => [
                            "goodsName",
                            "goodsPrice",
                            "linePrice",
                            "sellingPoint",
                            "goodsSales"
                        ]
                    ],
                    "data" => [
                        [
                            "goods_id" => 10020,
                            "goods_name" => "耐克 男子 NIKE AIR FORCE 1'07 运动鞋",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/10001/20210315/b72822760ccc4bb892cc658b33af939e.jpg",
                            "goods_price_min" => "749.00",
                            "goods_price_max" => "749.00",
                            "line_price_min" => "799.00",
                            "line_price_max" => "799.00",
                            "goods_sales" => 16
                        ],
                        [
                            "goods_id" => 10019,
                            "goods_name" => "清野の木 56L灰色特大号 塑料收纳箱整理箱环保加厚储物箱",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/10001/20210314/2a6e0c0ea7d1e5f0f2ac3e406198850c.jpg",
                            "goods_price_min" => "32.80",
                            "goods_price_max" => "32.80",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 172
                        ],
                        [
                            "goods_id" => 10018,
                            "goods_name" => "简约风条纹客厅沙发卧室床头抱枕靠垫套",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/10001/20210316/41cdb778199f99ebebb6090680f382fc.png",
                            "goods_price_min" => "99.00",
                            "goods_price_max" => "99.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 135
                        ],
                        [
                            "goods_id" => 10017,
                            "goods_name" => "三星 Galaxy S21 5G（SM-G9910）双模5G 骁龙888 超高清专业摄像 120Hz护目屏 游戏手机 8G+128G",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/10001/20210313/b51b4840c24250a67210d59e345e206d.jpg",
                            "goods_price_min" => "4969.00",
                            "goods_price_max" => "4969.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10016,
                            "goods_name" => "【舒尔健动感单车】大型健身器械 减肥神器",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/20190610131953961df5569.PNG",
                            "goods_price_min" => "1556.00",
                            "goods_price_max" => "1556.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 33
                        ],
                        [
                            "goods_id" => 10015,
                            "goods_name" => "荣耀 V10全网通 标配版 4GB+64GB 魅丽红 移动联通电信4G全面屏手机 双卡双待",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/2018071718294208f086786.jpg",
                            "goods_price_min" => "1899.00",
                            "goods_price_max" => "2199.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10014,
                            "goods_name" => "三星 Galaxy S9+（SM-G9650/DS）6GB+128GB 谜夜黑 移动联通电信4G 游戏手机 双卡双待",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/20180717182009cb6bf4951.jpg",
                            "goods_price_min" => "6999.00",
                            "goods_price_max" => "7199.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10013,
                            "goods_name" => "OPPO R15 直降300◆星云版新品手机 6G+128G R15梦境版 A3同款 R11S升级版 星云版 6+128G 官方标配",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/2018071718130695f254464.jpg",
                            "goods_price_min" => "2699.00",
                            "goods_price_max" => "2799.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10012,
                            "goods_name" => "vivo Z1 新一代全面屏 双摄拍照手机 移动联通电信4G 双卡双待 6GB+128GB 瓷釉黑",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/20180717180357119b95367.jpg",
                            "goods_price_min" => "2198.00",
                            "goods_price_max" => "2198.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10011,
                            "goods_name" => "Apple iPhone X (A1903) 64GB 深空灰色 移动联通4G手机",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/20180717175657d4f120465.jpg",
                            "goods_price_min" => "7099.00",
                            "goods_price_max" => "7299.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10010,
                            "goods_name" => "Apple iPhone 8 Plus (A1864) 64GB 深空灰色 移动联通电信4G手机",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/20180717174543802b79332.jpg",
                            "goods_price_min" => "5099.00",
                            "goods_price_max" => "5599.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10009,
                            "goods_name" => "荣耀9i 4GB+64GB 幻夜黑 移动联通电信4G全面屏手机 双卡双待",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/2018071717370507f183424.jpg",
                            "goods_price_min" => "1399.00",
                            "goods_price_max" => "1499.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10008,
                            "goods_name" => "华为 HUAWEI nova 3全面屏高清四摄游戏手机 6GB+128GB 浅艾蓝限量款 全网通移动联通电信4G手机 双卡双待",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/20180717172606d9aee7835.jpg",
                            "goods_price_min" => "2788.00",
                            "goods_price_max" => "2788.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ],
                        [
                            "goods_id" => 10007,
                            "goods_name" => "小米6X 全网通 4GB+32GB 流沙金 移动联通电信4G手机 双卡双待 智能手机",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/2018071716542894aea9466.jpg",
                            "goods_price_min" => "1399.00",
                            "goods_price_max" => "1699.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 363
                        ],
                        [
                            "goods_id" => 10006,
                            "goods_name" => "小米（MI） 红米6 流沙金 全网通(3G RAM+32G ROM)",
                            "selling_point" => "",
                            "goods_image" => "http://static.yoshop.xany6.com/2018071716364761fab9153.jpg",
                            "goods_price_min" => "739.00",
                            "goods_price_max" => "999.00",
                            "line_price_min" => "0.00",
                            "line_price_max" => "0.00",
                            "goods_sales" => 0
                        ]
                    ]
                ]
            ]
        ];
        return $this->success($data);
    }

    /**
     * 获取页面配置
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function getSetting()
    {
        $data = [
            'setting' => [
                'page_category_template' => ['style' => 20, 'shareTitle' => ''],
                'points' => ['points_name' => '积分', 'describe' => 'a) 积分不可兑现、不可转让,仅可在本平台使用) 您在本平台参加特定活动也可使用积分,详细使用规则以具体活动时的规则为准;\nc) 积分的数值精确到个位(小数点后全部舍弃,不进行四舍五入) 买家在完成该笔交易(订单状态为“已签收”)后才能得到此笔交易的相应积分,如购买商品参加店铺其他优惠,则优惠的金额部分不享受积分获取;'],
                'recharge' => ['is_entrance' => 1, 'is_custom' => 1, 'describe' => '1. 账户充值仅限微信在线方式支付，充值金额实时到账；2. 账户充值套餐赠送的金额即时到账；3. 账户余额有效期：自充值日起至用完即止；4. 若有其它疑问，可拨打客服电话400-000-1234']
            ]
        ];
        return $this->success($data);
    }

    /**
     * 获取全国行政区域（树形）
     *
     * @return \Illuminate\Http\JsonResponse
     */
    public function getRegionTree()
    {
        return $this->success(RegionService::getInstance()->getTree());
    }
}
